1
/****************************** Module Header ******************************\
2 * Module Name: GetDataForCallBack.aspx.cs
3 * Project: CSASPNETCascadingDropDown
4 * Copyright (c) Microsoft Corporation.
6 * This page is used to retrieve data in callback and write data to client.
8 * This source is subject to the Microsoft Public License.
9 * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
10 * All other rights reserved.
13 * * 7/24/2009 10:33 AM Thomas Sun Created
14 \***************************************************************************/
16 #region Using directives
18 using System
.Collections
;
19 using System
.Configuration
;
23 using System
.Web
.Security
;
25 using System
.Web
.UI
.HtmlControls
;
26 using System
.Web
.UI
.WebControls
;
27 using System
.Web
.UI
.WebControls
.WebParts
;
28 using System
.Xml
.Linq
;
29 using System
.Collections
.Generic
;
34 namespace CSASPNETCascadingDropDownList
36 public partial class GetDataForCallBack
: System
.Web
.UI
.Page
41 /// <param name="sender"></param>
42 /// <param name="e"></param>
43 protected void Page_Load(object sender
, EventArgs e
)
45 // Get querystring from URL and retrieve data basing on it
46 if (Request
.QueryString
.Count
> 0)
48 string strValue
= Request
.QueryString
[0];
49 if (Request
.QueryString
["country"] != null)
51 RetrieveRegionByCountry(strValue
);
55 RetrieveCityByRegion(strValue
);
62 /// Get region basing on country value
64 /// <param name="strValue">The country value</param>
65 public void RetrieveRegionByCountry(string strValue
)
67 List
<string> list
= RetrieveDataFromXml
.GetRegionByCountry(strValue
);
72 /// Get city basing on region value
74 /// <param name="strValue">The region value</param>
75 public void RetrieveCityByRegion(string strValue
)
77 List
<string> list
= RetrieveDataFromXml
.GetCityByRegion(strValue
);
82 /// Write data to client
84 /// <param name="list">The list contains value </param>
85 public void WriteData(List
<string> list
)
87 int iCount
= list
.Count
;
88 StringBuilder builder
= new StringBuilder();
91 for (int i
= 0; i
< iCount
- 1; i
++)
93 builder
.Append(list
[i
] + ",");
95 builder
.Append(list
[iCount
- 1]);
98 Response
.ContentType
= "text/xml";
99 // Write data in string format "###,###,###" to client
100 Response
.Write(builder
.ToString());